﻿<UserControl
    x:Class="FU.Capstones.IMS.Web.Silverlight.Views.ExportMaterialOrder"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Commands="clr-namespace:Microsoft.Practices.Prism.Commands;assembly=Microsoft.Practices.Prism"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    xmlns:Controls="clr-namespace:FU.Capstones.IMS.Web.Silverlight.Controls" 
    xmlns:Navigation="clr-namespace:Navigation.Silverlight;assembly=Navigation.Silverlight" 
    xmlns:TControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
    xmlns:Common="clr-namespace:FU.Capstones.IMS.Web.Common;assembly=FU.Capstones.IMS.Web.Common"
    xmlns:Groupbox="clr-namespace:Groupbox;assembly=Groupbox" 
    Navigation:ViewModel.TypeName="FU.Capstones.IMS.Web.Silverlight.ViewModels.ExportMaterialOrderViewModel"
    >

    <UserControl.Resources>
        <Common:DataContextProxy x:Key="DataContextProxy"/>
    </UserControl.Resources>
    <telerik:RadBusyIndicator 
        BusyContent="Đang kết nối tới máy chủ..." 
        IsBusy="{Binding Path=ServiceCallCounter, Converter={StaticResource IntegerToBoolConverter}}">
        <Grid x:Name="LayoutRoot" Style="{StaticResource ViewGridStyle}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <!--Title-->
            <Grid Grid.ColumnSpan="3">

                <Grid.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop0}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop1}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop2}"/>
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop3}"/>
                    </LinearGradientBrush>
                </Grid.Background>

                <TextBlock 
                        x:Name="lblTitle"                                     
                        Text="Đơn hàng xuất - nhập nguyên liệu"
                        Style="{StaticResource TextBlockTitlePageStyle}"/>
            </Grid>
            <Groupbox:GroupBox Grid.Column="1" Grid.Row="2">
                <Groupbox:GroupBox.Header>
                    <TextBlock Text="Thông tin đơn hàng" Style="{StaticResource TextBlockGroupBoxTitleStyle}"/>
                </Groupbox:GroupBox.Header>
                <Grid Margin="5,2">
                    <!--Text box field-->
                    <!--<Grid x:Name="TextBoxField" Grid.Column="1" Grid.Row="2">-->
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="40"/>
                            <RowDefinition Height="40"/>
                            <RowDefinition Height="40"/>
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <!--Person in charge-->
                        <TextBlock
                        Style="{StaticResource TextBlockNormalStyle}"
                        Grid.Column="0" Grid.Row="2">
                        <Run Text="Người làm hóa đơn " />
                        <Run Foreground="Red" Text="*" />
                        </TextBlock>
                        <ComboBox 
                        x:Name="cbPersonInCharge" 
                        Style="{StaticResource ComboBoxNormalStyle}"
                        Width="230"
                        Grid.Column="1" Grid.Row="2" HorizontalAlignment="Right"
                        ItemsSource="{Binding Path=EmployeeACollection, Mode=TwoWay}"
                        DisplayMemberPath="FullName"
                        SelectedItem="{Binding Path=MaterialOrder.EmployeeA, Mode=TwoWay}">
                        </ComboBox>

                        <!--Person order-->
                        <TextBlock
                        Style="{StaticResource TextBlockNormalStyle}"
                        Grid.Column="0" Grid.Row="1">
                        <Run Text="Người làm yêu cầu " />
                        <Run Foreground="Red" Text="*" />
                        </TextBlock>
                        <ComboBox 
                        x:Name="cbPersonOrderInternal" 
                        Style="{StaticResource ComboBoxNormalStyle}"
                        Width="230"
                        Grid.Column="1" Grid.Row="1" HorizontalAlignment="Right"
                        Visibility="{Binding Path=IsInternal, Mode=TwoWay,Converter={StaticResource BoolToVisibilityConverter}}"
                        ItemsSource="{Binding Path=EmployeeBCollection, Mode=TwoWay}"
                        DisplayMemberPath="FullName"
                        SelectedItem="{ Binding Path=MaterialOrder.EmployeeB,Mode=TwoWay}">
                        </ComboBox>
                        <ComboBox 
                        x:Name="cbPersonOrderExternal" 
                        Style="{StaticResource ComboBoxNormalStyle}"
                        Width="230"                         
                        Grid.Column="1" Grid.Row="1" 
                        HorizontalAlignment="Right"
                        Visibility="{Binding Path=IsExternal, Mode=TwoWay,Converter={StaticResource BoolToVisibilityConverter}}"
                        ItemsSource="{Binding Path=ContactCollection, Mode=TwoWay}"
                        DisplayMemberPath="FullName"
                        SelectedItem="{ Binding Path=MaterialOrder.Contact,Mode=TwoWay}">
                        </ComboBox>

                        <!--Store-->
                        <TextBlock
                        Style="{StaticResource TextBlockNormalStyle}"
                        Grid.Column="0" Grid.Row="3">
                        <Run Text="Kho " />
                        <Run Foreground="Red" Text="*" />
                        </TextBlock>
                        <ComboBox 
                        x:Name="cbStore" 
                        Style="{StaticResource ComboBoxNormalStyle}"
                        Width="230"
                        Grid.Column="1" Grid.Row="3" HorizontalAlignment="Right"
                        ItemsSource="{Binding Path=WarehouseCollection, Mode=TwoWay}"
                        DisplayMemberPath="WarehouseName"
                        SelectedItem="{Binding Path=SelectedWarehouse,Mode=TwoWay}">

                        </ComboBox>
                        <Grid Grid.Column="0" Grid.Row="0">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="Nhập ngày làm hóa đơn hoặc để trống" 
                               Grid.Row="0" Grid.Column="0"
                               Style="{StaticResource TextBlockNormalStyle}"
                               VerticalAlignment="Center"
                               HorizontalAlignment="Left">

                            </TextBlock>
                        <TControls:RadDatePicker
					            x:Name="txtCreateDate"
					            Grid.Row="2" Grid.Column="1" Width="230"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Center"
                                TextAlignment="Center"
                                IsReadOnly="{Binding Path=EnterDateIsReadOnly,  Mode=TwoWay}"
                                SelectedValue="{Binding Path=EnterDateTime, Mode=TwoWay}">
                        </TControls:RadDatePicker>
                    </Grid>
                        <Grid Grid.Column="1" Grid.Row="0">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <RadioButton GroupName="importExportButton" 
                                 x:Name="RadImport"
                                 Grid.Column="0" Grid.Row="0"
                                 IsChecked="{Binding Path=IsImported, Mode=TwoWay}"
                                 Command="{Binding Path=RadCheck, Mode=TwoWay}"
                                 Content="Nhập kho" Margin="10" />
                            <RadioButton GroupName="importExportButton" 
                                 x:Name="RadExport"
                                 Grid.Column="1" Grid.Row="0"
                                 IsChecked="{Binding Path=IsExported, Mode=TwoWay}"
                                 Command="{Binding Path=RadCheck, Mode=TwoWay}"
                                 Content="Xuất kho" Margin="10"/>
                            <RadioButton GroupName="internalExternalButton" 
                                 x:Name="RadEnteranl"
                                 Grid.Column="0" Grid.Row="1"
                                 IsChecked="{Binding Path=IsInternal, Mode=TwoWay}"
                                 Command="{Binding Path=RadInExCheck, Mode=TwoWay}"
                                 Content="Nội bộ" Margin="10" />
                            <RadioButton GroupName="internalExternalButton" 
                                 x:Name="RadExternal"
                                 Grid.Column="1" Grid.Row="1"
                                 IsChecked="{Binding Path=IsExternal, Mode=TwoWay}"
                                 Command="{Binding Path=RadInExCheck, Mode=TwoWay}"
                                 Content="Với đối tác" Margin="10"/>
                        </Grid>

                        <!--<TextBlock Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="3"
                           Foreground="Brown" Text=" _____Nguyên liệu xuất______________________________________________"
                           VerticalAlignment="Bottom" FontFamily="Times New Roman"
                           FontSize="13" />-->
                    <!--</Grid>-->


                </Grid>
            </Groupbox:GroupBox>
            
            <Groupbox:GroupBox Grid.Column="1" Grid.Row="3">
                <Groupbox:GroupBox.Header>
                    <TextBlock Text="Danh sách nguyên liệu" Style="{StaticResource TextBlockGroupBoxTitleStyle}"/>
                </Groupbox:GroupBox.Header>
                <Grid Margin="5,2">
                    <telerikGrid:RadGridView 
                        Width="Auto"
                        x:Name="grvOrderMaterial"
                        HorizontalAlignment="Left"                
                        Style="{StaticResource RadGridViewNormal}"
                        ItemsSource="{Binding Path=PagedCollectionMaterial}">
                        <telerikGrid:RadGridView.Columns>
                            
                        <telerikGrid:GridViewDataColumn 
                            DataMemberBinding="{Binding Path=MaterialCode,Mode=OneWay}"
                            TextAlignment="Right"
                            Header="Mã nguyên liệu"
                            Width="100" HeaderTextAlignment="Center">
                        </telerikGrid:GridViewDataColumn>
                            
                        <telerikGrid:GridViewDataColumn 
                            DataMemberBinding="{Binding Path=MaterialName}"
                            Header="Tên nguyên liệu"
                            Width="140" HeaderTextAlignment="Center"
                            TextAlignment="Right">
                        </telerikGrid:GridViewDataColumn>
                            
                        <telerikGrid:GridViewDataColumn                       
                            Header="Số lượng"
                            IsReadOnly="True"                       
                            Width="80" HeaderTextAlignment="Center" 
                            TextAlignment="Right"                                                 
                            DataMemberBinding="{Binding Path=Quantity}">
                        </telerikGrid:GridViewDataColumn>
                            
                        <telerikGrid:GridViewDataColumn                       
                            Header="Đơn giá"
                            Width="100" HeaderTextAlignment="Center"    
                            TextAlignment="Right"
                            DataMemberBinding="{Binding Path=PricePerUnit, Mode=TwoWay,Converter={StaticResource DecimalToVnCurrencyConverter}}">
                        </telerikGrid:GridViewDataColumn>
                            
                        <telerikGrid:GridViewColumn Width="Auto"  Header="Xóa" HeaderTextAlignment="Center" TextAlignment="Right">
                            <telerikGrid:GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <HyperlinkButton 
                                        Content="Xóa"    
                                        Commands:Click.Command="{Binding Path=DataSource.DeleteCommand, Source={StaticResource DataContextProxy}}"
                                        Commands:Click.CommandParameter="{Binding Path=MaterialID}"
                                    />
                                </DataTemplate>
                            </telerikGrid:GridViewColumn.CellTemplate>
                        </telerikGrid:GridViewColumn>
                    </telerikGrid:RadGridView.Columns>

                    </telerikGrid:RadGridView>
                </Grid>                
            </Groupbox:GroupBox>
            <StackPanel
                Orientation="Horizontal" HorizontalAlignment="Center"
                Grid.Column="1" Grid.Row="5">
                <!--Buttons-->
                <Controls:AddNewButtonControl  
                        HorizontalAlignment="Left"
                        Visibility ="{Binding Path=CanAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                        />
                <Controls:SaveButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:ResetButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:BackButtonControl
                    HorizontalAlignment="Right"
                    />
            </StackPanel>
        </Grid>
    </telerik:RadBusyIndicator>
</UserControl>
